package com.qingzhou.web.controller.common;

import com.qingzhou.common.web.domain.LoginBody;
import com.qingzhou.framework.dto.CurrentUser;
import com.qingzhou.framework.service.LoginService;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Result;

import java.util.Map;

/**
 * 认证 操作处理
 * @author xm
 */
@Controller
@Mapping
public class LoginController {

    @Inject
    LoginService loginService;

    /**
     * 登录
     */
    @Post
    @Mapping("login")
    public Map<String, Object> login(@Body LoginBody loginBody) {
        return loginService.login(loginBody);
    }

    /**
     * 获取登录用户信息
     */
    @Get
    @Mapping("getUserInfo")
    public CurrentUser getUserInfo() {
        return loginService.getUserInfo();
    }

    /**
     * 登出
     */
    @Delete
    @Mapping("logout")
    public Result<Void> logout() {
        loginService.logout();
        return Result.succeed();
    }

}
